var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, n) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var n in t)
              Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
          })(t, n);
      };
      return function (t, n) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        e(t, n),
          (t.prototype =
            null === n
              ? Object.create(n)
              : ((o.prototype = n.prototype), new o()));
      };
    })(),
  KnifeMeetingMainView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.tmpArr = []),
        (t.myGroupId = 1),
        t.btn_ddfh_back.on(Laya.Event.CLICK, t, t.onKnifeMeetingCancleFn),
        t.btn_ddfh_shuoming.on(Laya.Event.CLICK, t, t.onMainlickActionFn),
        t.btn_dandaofuhui_start.on(Laya.Event.CLICK, t, t.onMainlickActionFn),
        t.btn_zhenrong1.on(Laya.Event.CLICK, t, t.onSetZhenRongClick),
        t.btn_zhenrong2.on(Laya.Event.CLICK, t, t.onSetZhenRongClick),
        t.btn_zhenrong3.on(Laya.Event.CLICK, t, t.onSetZhenRongClick),
        WebSocketService.addListener({
          caller: t,
          code: 5289,
          method: t.onLoadPageMainData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5299,
          method: t.onLoadPageMainData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5298,
          method: t.onLoadPageMainData,
        }),
        (t.list_ddfh_item.selectEnable = !0),
        (t.list_ddfh_item.vScrollBarSkin = ""),
        (t.list_ddfh_item.renderHandler = new Handler(t, t.onRenderHandler)),
        t.list_ddfh_item.on(Laya.Event.CLICK, t, t.onDidListItemClick),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showBattleView = function () {
        return (
          null == this.dandaofuhuiV && (this.dandaofuhuiV = new t()),
          this.dandaofuhuiV.initPage(),
          this.dandaofuhuiV
        );
      }),
      (t.prototype.initPage = function () {
        WebSocketService.send({ c: 5289, d: { roleId: Global.roleId } }),
          WebSocketService.send({ c: 5299, d: { roleId: Global.roleId } }),
          (this.list_ddfh_item.visible = !1);
      }),
      (t.prototype.onLoadPageMainData = function (e) {
        if (5289 == e.act_id)
          0 == e.code
            ? "快去创建您的战斗阵容吧" != e.data && (this.myGroupId = e.data)
            : 8 == e.code &&
              "单刀赴会只能从城市中进入。" == e.msg &&
              this.onKnifeMeetingCancleFn();
        else if (5299 == e.act_id) {
          ToastView.toastView(e.msg);
          var t = [];
          e.data && (t = e.data),
            t.length > 0 && (this.list_ddfh_item.visible = !0),
            (this.tmpArr = []);
          for (var n = void 0, o = 0; o < t.length; o++) {
            var i = t[o];
            (n = {
              item_title: { text: i.notice },
              item_faqiren: { text: "发起人：" + i.name },
              item_zhanlipin: {
                text: "战利品：" + i.reward + Utils.getRewardType(i.rewardType),
              },
              roleId: i.roleId,
              sfRoleId: i.sfRoleId,
              groupId: i.groupId,
            }),
              this.tmpArr.push(n);
          }
          this.list_ddfh_item.dataSource = this.tmpArr;
        } else
          5298 == e.act_id &&
            (ToastView.toastView(e.msg),
            WebSocketService.send({ c: 5299, d: { roleId: Global.roleId } }));
      }),
      (t.prototype.onRenderHandler = function (e, t) {
        var n = e.getChildByName("item_tiaozhan");
        e.dataSource.roleId == Global.roleId
          ? ((n.label = "撤销"),
            (n.skin = "comp/commonpic/btn_dialog_silver.png"))
          : ((n.label = "挑战"),
            (n.skin = "comp/commonpic/btn_dialog_sure.png"));
      }),
      (t.prototype.onDidListItemClick = function (e) {
        if ("" != e.target.name) {
          var t = this.list_ddfh_item.selectedItem;
          if ("item_tiaozhan" == e.target.name)
            if (t.roleId == Global.roleId)
              WebSocketService.send({
                c: 5298,
                d: { groupId: t.groupId, state: 0 },
              });
            else {
              if (null == this.myGroupId || this.myGroupId <= 0) return;
              WebSocketService.send({
                c: 5304,
                d: {
                  roleId: t.roleId,
                  myGroupId: this.myGroupId,
                  otherGroupId: t.groupId,
                },
              });
            }
        }
      }),
      (t.prototype.onSetZhenRongClick = function (e) {
        var t = 1;
        "item_zr1" == e.target.name
          ? (t = 1)
          : "item_zr2" == e.target.name
          ? (t = 2)
          : "item_zr3" == e.target.name && (t = 3);
        var n = { groupId: t };
        ZhenRongDialog.showZhenRongDialog(n);
      }),
      (t.prototype.onMainlickActionFn = function (e) {
        if ("" != e.target.name)
          if ("item1" == e.target.name) {
            var t = RulesView.showCaslRuleView("dandaofuhui_shuoming");
            (t.y = 0), Laya.stage.addChild(t);
          } else
            "item_start" == e.target.name &&
              KnifeMeetStartDialog.showStartDanDaoFuHuiDialog("");
      }),
      (t.prototype.onKnifeMeetingCancleFn = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.battlefield.KnifeMeetingMainViewUI);
